﻿<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Base.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    ChangePassword
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <ext:Viewport ID="ViewPort1" runat="server" Layout="fit">
        <Items>
            <ext:FormPanel ID="FormPanel1" runat="server" Padding="5" DefaultAnchor="0" Frame="false"
                BodyBorder="false" Shadow="None">
                <Items>
                    <ext:TextField ID="txtOldPassword" runat="server" InputType="Password" FieldLabel="旧密码"
                        AllowBlank="false" BlankText="请输入用户名。" AnchorHorizontal="100%" ValidateOnBlur="true"
                        SelectOnFocus="true" />
                    <ext:TextField ID="txtNewPassword" runat="server" InputType="Password" FieldLabel="新密码"
                        AllowBlank="false" BlankText="请输入密码。" AnchorHorizontal="100%" ValidateOnBlur="true"
                        SelectOnFocus="true" />
                    <ext:TextField ID="txtNewPasswordConfirm" runat="server" InputType="Password" FieldLabel="再吃输入新密码"
                        AllowBlank="false" BlankText="请输入密码。" AnchorHorizontal="100%" ValidateOnBlur="true"
                        SelectOnFocus="true" />
                </Items>
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:Button ID="btnSave" runat="server" Text="保存" Icon="Disk">
                                <Listeners>
                                    <Click Fn="doSave" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
            </ext:FormPanel>
        </Items>
    </ext:Viewport>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderArea" runat="server">
    <script type="text/javascript" language="javascript">
        var _userid = '<%=ViewData("UserID") %>';

        var doSave = function (item, e) {
            if (txtNewPassword.getValue() == txtNewPasswordConfirm.getValue()) {
                $.ajax({
                    type: 'POST',
                    url: '<%= Url.Action("SavePassword","Account") %>',
                    data: { userid: _userid, oldpassword: txtOldPassword.getValue(), newpassword: txtNewPassword.getValue() },
                    success: function (data, textStatus) {
                        if (data == "Success") {
                            Ext.net.Notification.show({
                                iconCls: 'icon-information',
                                html: '保存记录成功',
                                title: '保存成功',
                                hideDelay: 5000
                            });
                        } else {
                            Ext.Msg.show({
                                title: 'DailyReport',
                                buttons: { yes: '确认' },
                                msg: data,
                                fn: function (btn) {
                                    txtOldPassword.setValue("");
                                    txtNewPassword.setValue("");
                                    txtNewPasswordConfirm.setValue("");
                                    return false;
                                }
                            });
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        Ext.net.Notification.show({
                            iconCls: 'icon-exclamation',
                            html: textStatus,
                            title: '出错啦',
                            hideDelay: 5000
                        });
                    }
                });
            } else {
                Ext.Msg.show({
                    title: 'DailyReport',
                    buttons: { yes: '确认' },
                    msg: '两次输入的新密码不一致，请重新输入。',
                    fn: function (btn) {
                        txtNewPassword.setValue("");
                        txtNewPasswordConfirm.setValue("");
                        return false;
                    }
                });
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="StartupArea" runat="server">
</asp:Content>
